home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* */
- /* ------------ Bit-Bucket Software <no-Inc> */
- /* \ 10001101 / Writers and Distributors of */
- /* \ 011110 / No-Cost<no-tm> Software. */
- /* \ 1011 / */
- /* ------ */
- /* */
- /* Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello */
- /* */
- /* */
- /* BinkleyTerm "SendWaZOO" Processor */
- /* */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the MAKEFILE and BT.C, and also contained in the file LICENSE.210. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT THE AUTHORS */
- /* AT THE ADDRESSES LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO */
- /* USE THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE */
- /* BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU */
- /* ARE ABLE TO REACH WITH THE AUTHORS. */
- /* */
- /* */
- /* The Authors can be reached at the following addresses: */
- /* */
- /* Robert C. Hartman Vincent E. Perriello */
- /* Spark Software VEP Software */
- /* 427-3 Amherst Street 111 Carroll Street */
- /* CS2032, Suite 232 Naugatuck, CT 06770 */
- /* Nashua, NH 03061 */
- /* */
- /* FidoNet 1:132/101 FidoNet 1:141/491 */
- /* Data (603) 888-8179 Data (203) 729-7569 */
- /* */
- /* Please feel free to contact us at any time to share your comments */
- /* about our software and/or licensing policies. */
- /* */
- /* */
- /* This module is based largely on a similar module in OPUS-CBCS V1.03b. */
- /* The original work is (C) Copyright 1987, Wynn Wagner III. The original */
- /* author has graciously allowed us to use his code in this work. */
- /* */
- /*--------------------------------------------------------------------------*/
-
- #include <signal.h>
- #include <ctype.h>
- #include <conio.h>
- #include <string.h>
-
- #define WAZOO_SECTION
- #include "com.h"
- #include "xfer.h"
- #include "zmodem.h"
- #include "keybd.h"
- #include "sbuf.h"
- #include "sched.h"
- #include "externs.h"
- #include "prototyp.h"
-
- #define rb_plus "r+b"
-
- int WaZOO_callback (char *);
- static int fsent;
-
- #define NUM_FLAGS 4
-
-
- /*--------------------------------------------------------------------------*/
- /* SEND WaZOO (send another WaZOO-capable Opus its mail) */
- /* returns TRUE (1) for good xfer, FALSE (0) for bad */
- /* use instead of n_bundle and n_attach for WaZOO Opera */
- /*--------------------------------------------------------------------------*/
- int send_WaZOO ()
- {
- char fname[80];
- char s[80];
- char *HoldName;
- int c;
- struct stat buf;
-
-
- fsent = 0;
-
- HoldName = HoldAreaNameMunge(called_zone);
-
- /*--------------------------------------------------------------------*/
- /* Send all waiting ?UT files (mail packets) */
- /*--------------------------------------------------------------------*/
- *ext_flags = 'O';
- for (c = 0; c < NUM_FLAGS; c++)
- {
- #ifndef JACK_DECKER
- if (caller && (ext_flags[c] == 'H'))
- continue;
- #endif
-
- sprintf (fname,
- "%s%04x%04x.%cUT",
- HoldName, called_net, called_node, ext_flags[c]);
- errno = 0;
-
- if (!stat (fname, &buf))
- {
-
- /*--- Build a dummy PKT file name */
- invent_pkt_name (s);
-
- /*--- Tell ZModem to handle this as a SEND AS then DELETE */
- status_line (PACKET_msg);
-
- if (!(*wzsendfunc) (fname, s, fsent++, DO_WAZOO))
- {
- net_problems = 1;
- return FALSE;
- }
- CLEAR_IOERR ();
- unlink (fname);
- got_error (UNLINK_msg, fname);
- }
- } /* for */
-
- /*--------------------------------------------------------------------*/
- /* Send files listed in ?LO files (attached files) */
- /*--------------------------------------------------------------------*/
- *ext_flags = 'F';
- if (!do_FLOfile (ext_flags, WaZOO_callback))
- return FALSE;
-
- /*--------------------------------------------------------------------*/
- /* Send our File requests to other system */
- /*--------------------------------------------------------------------*/
- if (requests_ok)
- {
- sprintf (fname, request_template, HoldName, called_net, called_node);
- if (!stat (fname, &buf))
- {
- if (!(remote_capabilities & WZ_FREQ))
- status_line ("*F.REQ. declined");
- else
- {
- status_line ("*Making file request");
- ++made_request;
- if ((*wzsendfunc) (fname, NULL, fsent++, DO_WAZOO))
- unlink (fname);
- }
- }
- }
-
- fsent = respond_to_file_requests (fsent, WaZOO_callback);
-
- errno = 0;
- if (!fsent)
- status_line (NothingToSend_msg,
- alias[assumed].Zone, alias[assumed].Net, alias[assumed].Node,
- called_zone, called_net, called_node);
-
- (*wzsendfunc) (NULL, NULL, ((fsent) ? END_BATCH : NOTHING_TO_DO), DO_WAZOO);
-
- sent_mail = 1;
-
- return TRUE;
-
- } /* WaZOO */
-
- /*--------------------------------------------------------------------------*/
- /* RESPOND TO FILE REQUEST */
- /*--------------------------------------------------------------------------*/
- int respond_to_file_requests (f_sent, callback)
- int f_sent;
- int (*callback)(char *);
- {
- char req[80];
- struct stat buf;
- int n_frproc (char *, int, int (*)(char *));
- int nfiles = 0;
- FILE *fp;
- int np;
- byte *s;
-
- fsent = f_sent; /* copy into local var */
- /* this is for callback */
- if (!(matrix_mask & TAKE_REQ))
- goto done;
-
- for (np = 0; np <= ALIAS_CNT; np++)
- {
- if (alias[np].Net == 0)
- break;
-
- sprintf (req, request_template, CurrentNetFiles,
- alias[np].Net, alias[np].Node);
-
- if (!stat (req, &buf))
- {
- errno = 0;
- fp = fopen (req, read_ascii);
- if (got_error (OPEN_msg, req))
- goto done;
- while (!feof (fp))
- {
- req[0] = 0;
- if (fgets (req, 79, fp) == NULL)
- break;
-
- /* ; as the first char is a comment */
- if (req[0] == ';')
- continue;
-
- /* Get rid of the newline at the end */
- s = req + strlen (req) - 1;
- while ((s >= req) && isspace (*s))
- *s-- = '\0';
-
- if (req[0] == '\0')
- continue;
-
- if ((nfiles = n_frproc (req, nfiles, callback)) < 0)
- break;
- }
-
- sprintf (req, request_template, CurrentNetFiles,
- alias[np].Net, alias[np].Node);
- errno = 0;
- fclose (fp);
- got_error (CLOSE_msg, req);
-
- /* Note that Opus does not delete this file, but we should I think */
- unlink (req);
- got_error (UNLINK_msg, req);
- /* once we have satisfied a request, we can get out of here */
- break;
- }
- }
-
- done:
- return fsent;
- }
-
- /*
- * WaZOO_callback () -- send requested file using WaZOO method.
- *
- *
- */
- int WaZOO_callback (reqs)
- char *reqs;
- {
- return ((*wzsendfunc) (reqs, NULL, fsent++, DO_WAZOO));
- }
-